using System;
using System.Collections;

namespace WebApplication
{
	[Serializable]
	public class BidCollection : ICollection
	{
		private ArrayList  _aBids;

		public void RemoveBidsOnThisCompany (string sCompany)
		{
			for (int i = _aBids.Count - 1; i >= 0; i--)
			{
				Bid bid = (Bid) _aBids[i];

				if (bid.CompanyName == sCompany)
				{
					_aBids.RemoveAt (i);
				}
			}
		}

		public Bid this [int index]   // indexer declaration
		{ 
			get
			{
				return (Bid) _aBids[index];
			}

			set
			{
				_aBids[index] = value;
			}
		}

		public void CopyTo(Array a, int index)
		{
			_aBids.CopyTo(a, index);
		}
		public object SyncRoot
		{
			get{return this;}
		}
		public bool IsSynchronized
		{
			get{return false;}
		}

		public int Count
		{
			get
			{
				return _aBids.Count;
			}
		}

		public BidCollection ()
		{
			_aBids = new ArrayList ();
		}

		public void Add (System.Object BidCompany)
		{
			_aBids.Add (BidCompany);
		}

		public void Add (Bid bid)
		{
			_aBids.Add (bid);
		}

		public void Remove (Bid bid)
		{
			_aBids.Remove (bid);
		}

		// IEnumerable Interface Implementation:

		public IEnumerator GetEnumerator() // non-IEnumerable version
		{
			return _aBids.GetEnumerator ();
		}

		IEnumerator IEnumerable.GetEnumerator() // IEnumerable version
		{
			//			return (IEnumerator) new BidEnumerator(this);
			return _aBids.GetEnumerator ();
		}
	}


	[Serializable]
	public class Bid
	{
		private string _sCompanyName;  

		public string CompanyName
		{
			get
			{
				return _sCompanyName;
			}
			set
			{
				_sCompanyName = value;
			}
		}

		private int _nAmount;  // 45+

		public int Amount
		{
			get
			{
				return _nAmount;
			}
			set
			{
				_nAmount = value;
			}
		}

		private string _sPlayer;
		public string Player
		{
			get
			{
				return _sPlayer;
			}
			set
			{
				_sPlayer = value;
			}
		}

		public Bid () // default cons
		{
			_nAmount = 0;
		}
	}
}
